package com.honglv.controller.common;

import com.honglv.exception.BaseException;
import com.honglv.pojo.dto.PageByCityDTO;
import com.honglv.pojo.result.Result;
import com.honglv.pojo.vo.GetAttractionsByCityVO;
import com.honglv.pojo.vo.GetAttractionsByCityVO;
import com.honglv.pojo.vo.PageVO;
import com.honglv.service.AttractionsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api("景点相关接口")

public class AttractionsController {
    @Autowired
    private AttractionsService attractionsService;

    /**
     * 根据城市分页获取景点
     * @param
     * @return
     */
    @GetMapping("/getAttractionsByCity")
    @ApiOperation("根据城市分页获取酒店")
    public Result<PageVO<GetAttractionsByCityVO>> getAttractionsByCity(PageByCityDTO pageByCityDTO){
        if (pageByCityDTO == null || pageByCityDTO.getPageSize() == null || pageByCityDTO.getPage() == null){
            throw new BaseException("参数为空");
        }
        PageVO<GetAttractionsByCityVO> pageVO = attractionsService.getAttractionsByCity(pageByCityDTO);
        if (pageVO == null){
            return Result.success("暂无景点数据");
        }
        return Result.success(pageVO);
    }
}
